services: fix switch statements to comply with MISRA rules
authorJonathan Wright <[email protected]>
Wed, 14 Mar 2018 15:56:21 +0000 (15:56 +0000)
committerJonathan Wright <[email protected]>
Mon, 26 Mar 2018 11:43:05 +0000 (12:43 +0100)
Ensure (where possible) that switch statements in services comply with
MISRA rules 16.1 - 16.7.

Change-Id: I47bf6ed4a026201e6fe125ce51842482e99e8bb0
Signed-off-by: Jonathan Wright <[email protected]>
services/spd/opteed/opteed_main.c
services/spd/tlkd/tlkd_common.c
services/spd/tlkd/tlkd_main.c
services/spd/tspd/tspd_main.c
services/std_svc/sdei/sdei_main.c

index 13a307a2a24be8e47844683f2049c392ba0f6b60..3d679806c285b2b56bd935d91f5b761b0269f480 100644 (file)
@@ -311,6 +311,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid,
                 * OPTEE. Jump back to the original C runtime context.
                 */
                opteed_synchronous_sp_exit(optee_ctx, x1);
+               break;
 
 
        /*
@@ -345,6 +346,7 @@ uint64_t opteed_smc_handler(uint32_t smc_fid,
                 * return value to the caller
                 */
                opteed_synchronous_sp_exit(optee_ctx, x1);
+               break;
 
        /*
         * OPTEE is returning from a call or being preempted from a call, in
index 483d45b689d03b35641c48999a3b0a3c82946b5f..d846269b9649e6a1881813a098ce973593ada255 100644 (file)
@@ -49,6 +49,7 @@ uint64_t tlkd_va_translate(uintptr_t va, int type)
                break;
        default:
                assert(0);
+               break;
        }
 
        /* get the (NS/S) physical address */
index cb68bff76f4f285418cd9ddca9cec07841e57458..da3b732e55df32ef88c3f61367e5197c397e70ec 100644 (file)
@@ -350,6 +350,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
                 * context.
                 */
                tlkd_synchronous_sp_exit(&tlk_ctx, x1);
+               break;
 
        /*
         * These function IDs are used only by TLK to indicate it has
@@ -375,6 +376,7 @@ uint64_t tlkd_smc_handler(uint32_t smc_fid,
                 * return value to the caller
                 */
                tlkd_synchronous_sp_exit(&tlk_ctx, x1);
+               break;
 
        /*
         * Return the number of service function IDs implemented to
index 3d06e0b81d7d142b677689b9f18dbffed36cd133..2312205c807a29927aa62e43992759dae264ae0b 100644 (file)
@@ -435,6 +435,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
                 * context.
                 */
                tspd_synchronous_sp_exit(tsp_ctx, x1);
+               break;
 #endif
        /*
         * This function ID is used only by the SP to indicate it has finished
@@ -475,6 +476,7 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
                 * return value to the caller
                 */
                tspd_synchronous_sp_exit(tsp_ctx, x1);
+               break;
 
                /*
                 * Request from non-secure client to perform an
@@ -591,7 +593,6 @@ uint64_t tspd_smc_handler(uint32_t smc_fid,
                        SMC_RET3(ns_cpu_context, x1, x2, x3);
                }
 
-               break;
        /*
         * Request from the non-secure world to abort a preempted Yielding SMC
         * Call.
index 1969307fd7601077a13747e6021c534cf9ad6541..9589a252e74ffb3d0f24b1ee1466af0977856fc0 100644 (file)
@@ -916,7 +916,6 @@ uint64_t sdei_smc_handler(uint32_t smc_fid,
                ret = sdei_version();
                SDEI_LOG("< VER:%lx\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_REGISTER:
                x5 = SMC_GET_GP(handle, CTX_GPREG_X5);
@@ -925,32 +924,27 @@ uint64_t sdei_smc_handler(uint32_t smc_fid,
                ret = sdei_event_register(x1, x2, x3, x4, x5);
                SDEI_LOG("< REG:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_ENABLE:
                SDEI_LOG("> ENABLE(n:%d)\n", (int) x1);
                ret = sdei_event_enable(x1);
                SDEI_LOG("< ENABLE:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_DISABLE:
                SDEI_LOG("> DISABLE(n:%d)\n", (int) x1);
                ret = sdei_event_disable(x1);
                SDEI_LOG("< DISABLE:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_CONTEXT:
                SDEI_LOG("> CTX(p:%d):%lx\n", (int) x1, read_mpidr_el1());
                ret = sdei_event_context(handle, x1);
                SDEI_LOG("< CTX:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_COMPLETE_AND_RESUME:
                resume = 1;
-               /* Fall through */
 
        case SDEI_EVENT_COMPLETE:
                SDEI_LOG("> COMPLETE(r:%d sta/ep:%lx):%lx\n", resume, x1,
@@ -969,92 +963,81 @@ uint64_t sdei_smc_handler(uint32_t smc_fid,
                        SMC_RET1(handle, ret);
 
                SMC_RET0(handle);
-               break;
 
        case SDEI_EVENT_STATUS:
                SDEI_LOG("> STAT(n:%d)\n", (int) x1);
                ret = sdei_event_status(x1);
                SDEI_LOG("< STAT:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_GET_INFO:
                SDEI_LOG("> INFO(n:%d, %d)\n", (int) x1, (int) x2);
                ret = sdei_event_get_info(x1, x2);
                SDEI_LOG("< INFO:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_UNREGISTER:
                SDEI_LOG("> UNREG(n:%d)\n", (int) x1);
                ret = sdei_event_unregister(x1);
                SDEI_LOG("< UNREG:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_PE_UNMASK:
                SDEI_LOG("> UNMASK:%lx\n", read_mpidr_el1());
                sdei_pe_unmask();
                SDEI_LOG("< UNMASK:%d\n", 0);
                SMC_RET1(handle, 0);
-               break;
 
        case SDEI_PE_MASK:
                SDEI_LOG("> MASK:%lx\n", read_mpidr_el1());
                ret = sdei_pe_mask();
                SDEI_LOG("< MASK:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_INTERRUPT_BIND:
                SDEI_LOG("> BIND(%d)\n", (int) x1);
                ret = sdei_interrupt_bind(x1);
                SDEI_LOG("< BIND:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_INTERRUPT_RELEASE:
                SDEI_LOG("> REL(%d)\n", (int) x1);
                ret = sdei_interrupt_release(x1);
                SDEI_LOG("< REL:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_SHARED_RESET:
                SDEI_LOG("> S_RESET():%lx\n", read_mpidr_el1());
                ret = sdei_shared_reset();
                SDEI_LOG("< S_RESET:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_PRIVATE_RESET:
                SDEI_LOG("> P_RESET():%lx\n", read_mpidr_el1());
                ret = sdei_private_reset();
                SDEI_LOG("< P_RESET:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_ROUTING_SET:
                SDEI_LOG("> ROUTE_SET(n:%d f:%lx aff:%lx)\n", (int) x1, x2, x3);
                ret = sdei_event_routing_set(x1, x2, x3);
                SDEI_LOG("< ROUTE_SET:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_FEATURES:
                SDEI_LOG("> FTRS(f:%lx)\n", x1);
                ret = sdei_features(x1);
                SDEI_LOG("< FTRS:%lx\n", ret);
                SMC_RET1(handle, ret);
-               break;
 
        case SDEI_EVENT_SIGNAL:
                SDEI_LOG("> SIGNAL(e:%lx t:%lx)\n", x1, x2);
                ret = sdei_signal(x1, x2);
                SDEI_LOG("< SIGNAL:%ld\n", ret);
                SMC_RET1(handle, ret);
-               break;
+
        default:
+               /* Do nothing in default case */
                break;
        }